﻿using Gamelight.Graphics;
using Gamelight.Input;
using Gamelight.Scene;
using Gamelight.Sound;

namespace TestProject
{
	public class TestScene : GameSceneBase
	{
		private Image testImage = new Image("Images/bad_kitty.jpeg");
		private Sound testSound = new Sound("Sounds/bad.wav");

		private int x = 0;
		private int y = 0;

		protected override void Initialize()
		{
			
		}

		protected override void ProcessInput(InputEvent[] events)
		{
			foreach (InputEvent e in events)
			{
				if (e.Type == EventType.KeyDown && e.Key == Key.X)
				{
					SoundManager.PlaySound(this.testSound);
				}
			}
		}

		protected override void Update(int gameCounter)
		{
			this.x += 2;
			this.y++;

			this.x = this.x % 640;
			this.y = this.y % 480;
		}

		protected override void Render(Image gameScreen)
		{
			gameScreen.Fill(Colors.Black);

			gameScreen.Blit(this.testImage, 100, 100);

			foreach (int xOffset in new int[] { 0, -640 })
			{
				foreach (int yOffset in new int[] { 0, -480 })
				{
					Draw.Rectangle(gameScreen, Colors.Red, this.x - xOffset, this.y - yOffset, 20, 20);
				}
			}
		}
	}
}
